<template>
  <div class="topbar">
    <div class="topbar_title">笔记</div>
    <div class="topbar_type">
      <div class="topbar_type_option" @click="setType('read')"
        :style="MainStore.state.type == 'read'? 'background-color: rgb(197, 191, 191);': ''"
      >
        <img src="@/assets/icons/read.png" class="icons" alt="">
      </div>
      <div class="topbar_type_option" @click="setType('edit')" 
        :style="MainStore.state.type == 'edit'? 'background-color: rgb(197, 191, 191);': ''"
      >
        <img src="@/assets/icons/bianji.png" class="icons" alt="">
      </div>
      <div class="topbar_type_option" @click="setType('plan')" 
        :style="MainStore.state.type == 'plan'? 'background-color: rgb(197, 191, 191);': ''"
      >
        <img src="@/assets/icons/lingan.png" class="icons" alt="">
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { useMainStore } from "@/store/index";
const MainStore = useMainStore();

function setType(type: string) {
  MainStore.state.type = type;
}
</script>

<style lang="scss" scoped>
.topbar {
  font-size: 14px;
  height: 30px;
  display: flex;
  padding: 0px 10px;
  justify-content: space-between;
  align-items: center;
  align-content: center;

  >.topbar_title {
    flex-grow: 1;
  }

  >.topbar_type {
    display: flex;

    >.topbar_type_option {
      margin-right: 10px;
      border: 1px solid rgb(197, 191, 191);
      display: flex;
      background-color: rgb(219, 213, 213);
      justify-content: center;
      align-items: center;
      border-radius: 15px;
      padding: 2px;
      >.icons{
        width: 16px;
        height: 16px;
      }
    }
    >.topbar_type_option:hover{
      background-color: rgb(197, 191, 191);
    }
  }

}
</style>